package com.power.mock.mockstatic;

import com.alibaba.fastjson.JSON;
import com.google.inject.Inject;
import com.power.mock.User;
import com.power.mock.init.PowerInit;
import com.power.mock.util.WJedisHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author wangjianxin01
 */
public class UserService {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    public UserService() {
        PowerInit.injector.injectMembers(this);
    }


    @Inject
    private UserDAO userDAO;


    public void saveUserToDBAndCache(User user) {
        logger.info("in method UserService.saveUserToDBAndCache(User user), user = {}", user);
        userDAO.saveUser(user);
        WJedisHelper.getHelper("appName").set("user", JSON.toJSONString(user), WJedisHelper.ONE_HALF_DAY);
    }


}
